﻿@using DevExpress.Blazor
@using DevExpress.ExpressApp.Blazor.Components
@using EasyXaf.LowCode.WorkflowEditors.Models.Activities
@using Microsoft.AspNetCore.Components.Web

<div class="@NodeComponentClassName" style="@NodeComponentStyle">
    <div class="node-icon" @onclick="ChangeViewMode">
        <XafImage ImageName="@Node.ImageName" Size="@(MiniMode?16:24)" Color="@Node.Color" />
    </div>
    <div class="node-description">
        @if (CaptionEditing)
        {
            <DxMemo @ref="CaptionMemo"
                    @bind-Text="CaptionValue"
                    @onfocusout="EndEditCaption"
                    @onkeydown="ProcessMemoKeyDown"
                    CssClass="w-100"
                    Rows="@(MiniMode?2:3)"
                    SizeMode="SizeMode.Small"
                    BindValueMode="BindValueMode.OnLostFocus" />
        }
        else
        {
            <span @ondblclick="BeginEditCaption" @ondblclick:stopPropagation>
                @Node.Caption
            </span>
        }
    </div>
    @if (!CaptionEditing)
    {
        <div class="action hidden-action node-right-bottom-toolbar">
            @if (Node is IContainerActivity containerActivity)
            {
                <NodeAction Tooltip="进入"
                            IconName="Actions_Arrow4RightDown"
                            IconColor="#7F8C8D"
                            Click="EnterContainer" />
            }
            @if (!IsReadOnly)
            {
                <NodeAction Tooltip="更多..."
                            IconName="Action_More"
                            IconColor="#7F8C8D"
                            Click="ShowNodeMenu" />
            }
        </div>
    }
</div>
